<?php
namespace cosocket\system\database\wrappers;

use cosocket\system\database\pools\MysqlPool;
use cosocket\system\Debug;

class MysqlWrapper
{
    private $mysqli = null;
    private $name = null;

    public function __construct($name,$mysqli)
    {
        $this->name = $name;
        $this->mysqli = $mysqli;
    }

    public  function  __destruct()
    {
        if($this->mysqli){
            Debug::info("MysqlWrapper __destruct");
            MysqlPool::put($this->name,$this->mysqli);
        }
    }

    public function __get($name){
        return $this->mysqli->$name;
    }

    public function __call($fname, $arguments)
    {
        return $this->mysqli->$fname(...$arguments);
    }
}